package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbChargingpiles;
import com.ruoyi.system.service.ITbChargingpilesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充电桩状态监控Controller
 *
 * @author ruoyi
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/system/chargingpiles")
public class TbChargingpilesController extends BaseController
{
    @Autowired
    private ITbChargingpilesService tbChargingpilesService;

    /**
     * 查询充电桩状态监控列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TbChargingpiles tbChargingpiles)
    {
        startPage();
        List<TbChargingpiles> list = tbChargingpilesService.selectTbChargingpilesList(tbChargingpiles);
        return getDataTable(list);
    }

    /**
     * 导出充电桩状态监控列表
     */
    @Log(title = "充电桩状态监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbChargingpiles tbChargingpiles)
    {
        List<TbChargingpiles> list = tbChargingpilesService.selectTbChargingpilesList(tbChargingpiles);
        ExcelUtil<TbChargingpiles> util = new ExcelUtil<TbChargingpiles>(TbChargingpiles.class);
        util.exportExcel(response, list, "充电桩状态监控数据");
    }

    /**
     * 获取充电桩状态监控详细信息
     */
    @GetMapping(value = "/{cid}")
    public AjaxResult getInfo(@PathVariable("cid") Long cid)
    {
        return success(tbChargingpilesService.selectTbChargingpilesByCid(cid));
    }

    /**
     * 新增充电桩状态监控
     */
    @Log(title = "充电桩状态监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbChargingpiles tbChargingpiles)
    {
        return toAjax(tbChargingpilesService.insertTbChargingpiles(tbChargingpiles));
    }

    /**
     * 修改充电桩状态监控
     */
    @Log(title = "充电桩状态监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbChargingpiles tbChargingpiles)
    {
        return toAjax(tbChargingpilesService.updateTbChargingpiles(tbChargingpiles));
    }

    /**
     * 删除充电桩状态监控
     */
    @Log(title = "充电桩状态监控", businessType = BusinessType.DELETE)
    @DeleteMapping("/{cids}")
    public AjaxResult remove(@PathVariable Long[] cids)
    {
        return toAjax(tbChargingpilesService.deleteTbChargingpilesByCids(cids));
    }
    /**
     * 获取充电桩分析详细信息
     */
    @GetMapping(value = "/ana/ana")
    public AjaxResult getAnalyse()
    {
        return success(tbChargingpilesService.getChargingPileAnalysis());
    }
}
